public class Demo26 {
    public static void main(String[] args) throws InterruptedException {
        Object locker1 = new Object();
        //Object locker2 = new Object();
        Thread t1 = new Thread(() -> {
            System.out.println("t1 等待之前");
            synchronized(locker1){
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1 等待之后");
        });
        Thread t2 = new Thread(() -> {
            System.out.println("t2 等待之前");
            synchronized (locker1){
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t2 等待之后");
        });
        Thread t3 = new Thread(() -> {
            System.out.println("t3 通知之前");
            synchronized(locker1) {
                locker1.notifyAll();
            }
            System.out.println("t3 通知之后");
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        t3.start();
    }
}
